export const retryOperation = async (
  operation: () => Promise<any>,
  maxAttempts: number = 5,
  delay: number = 5000
): Promise<any> => {
  let attempts = 0

  while (attempts < maxAttempts) {
    try {
      return await operation()
    } catch (error) {
      attempts++
      console.error(`Operation failed. Attempt ${attempts}/${maxAttempts}`)

      if (attempts === maxAttempts) {
        throw error
      }

      await new Promise((resolve) => setTimeout(resolve, delay))
    }
  }
}
